

var osou = document.querySelector('.sou')
var put = document.querySelector('input')

var userinfo = JSON.parse(localStorage.getItem('userinfo'))
osou.onclick = () => {
    axios.get('/user/search', { params: { searchkey: put.value } }).then((res) => {
        read(res.data.list)
        console.log(res.data);
    })
}

var otbody = document.querySelector('tbody')
otbody.onclick = (e) => {
    if (e.target.tagName == 'SPAN' && e.target.classList.contains('icon-shanchu')) {
        // console.log(e.target.dataset.phone);
        axios.post('/user/delete', { phone: e.target.dataset.phone }).then((res) => {
            console.log(res.data.list);
            read(res.data.list)
        })
    }
}
function read(data) {
    var str = ''
    var str = data.map((item, index) => {
        return `<tr>
                <td>1</td>
                <td>${item.phone}</td>
                <td>${item.ingroup}</td>             
                <td>${item.num}</td>
                 
                <td>${item.num}</td>
                <td>2020-09-${item.day}</td>
                <td> <button>删除</button> </td>
                </tr>
                `
    }).join('')

    document.querySelector('tbody').innerHTML = str;
}
axios.get('/user/list', { params: { page: 1, count: 5} }).then((res) => {
    read(res.data.list)
})

